package com.mzy.datepackage.M2021.Dec.Eleven;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Ives
 * * @date 2021/11/12
 */
public class Test {

  public static void main(String[] args) {
    SecondSimOrderedServiceGroupDTO secondSimOrderedServiceGroupDTO = new SecondSimOrderedServiceGroupDTO();
    JSON json = new JSONObject();
//    secondSimOrderedServiceGroupDTO.setOrderId(11l);
//    for (SecondSimOrderedServiceDTO secondSimOrderedServiceDTO : secondSimOrderedServiceGroupDTO.getSecondSimOrderedServiceDTOList()) {
//      OrderedServiceVO orderedServiceVO = new OrderedServiceVO();
////      secondSimOrderedServiceDTO.setOrderedServices(orderedServiceVO);
//    }
//    secondSimOrderedServiceGroupDTO.getSecondSimOrderedServiceDTOList().set(2,new SecondSimOrderedServiceDTO());

    secondSimOrderedServiceGroupDTO.setOrderId(1l);
    SecondSimOrderedServiceDTO secondSimOrderedServiceDTO = new SecondSimOrderedServiceDTO();
    OrderedServiceVO orderedServiceVO = new OrderedServiceVO();
    orderedServiceVO.setDefaultExpand(true);
    orderedServiceVO.setOfferCategoryId(123l);
    ArrayList<OrderedOffer> list1 = new ArrayList<>();
    OrderedOffer orderedOffer = new OrderedOffer();
    orderedOffer.setActiveDt("asda");
    orderedOffer.setBundleId(123l);
    list1.add(orderedOffer);
    orderedServiceVO.setOffers(list1);

    ArrayList<OrderedServiceVO> list2 = new ArrayList<>();
    list2.add(orderedServiceVO);
    secondSimOrderedServiceDTO.setOrderedServices(list2);
    //
    ArrayList<ServiceNumberExternal> list4 = new ArrayList<>();
    ServiceNumberExternal serviceNumberExternal = new ServiceNumberExternal();
    serviceNumberExternal.setExternalId("123");
    serviceNumberExternal.setChoose(true);
    serviceNumberExternal.setId(1234l);
    serviceNumberExternal.setExternalIdTypeName("jiegouces");
    list4.add(serviceNumberExternal);
    secondSimOrderedServiceDTO.setExternalObjectList(list4);


    // fajin
    OrderOffWaiVO orderOffWaiVO = new OrderOffWaiVO();
    orderOffWaiVO.setAmountSum(new BigDecimal(123));
    secondSimOrderedServiceDTO.setPenaltyVO(orderOffWaiVO);
    secondSimOrderedServiceDTO.setPenaltyVO(orderOffWaiVO);

    secondSimOrderedServiceDTO.setServiceNumber("fuwuhaoma");
    secondSimOrderedServiceDTO.setIsMainNumber(true);

    ArrayList<SecondSimOrderedServiceDTO> list3 = new ArrayList<>();
    list3.add(secondSimOrderedServiceDTO);
    secondSimOrderedServiceGroupDTO.setSecondSimOrderedServiceDTOList(list3);
    String s1 = json.toJSONString(secondSimOrderedServiceGroupDTO,true);
//    String s2 = secondSimOrderedServiceGroupDTO.toString();
//    System.out.println(s2);

    System.out.println(s1);


  }

  @org.testng.annotations.Test
  public void demo(){
    SecondSimOrderedServiceGroupDTO secondSimOrderedServiceGroupDTO = new SecondSimOrderedServiceGroupDTO();
    JSON json = new JSONObject();
//    secondSimOrderedServiceGroupDTO.setOrderId(11l);
//    for (SecondSimOrderedServiceDTO secondSimOrderedServiceDTO : secondSimOrderedServiceGroupDTO.getSecondSimOrderedServiceDTOList()) {
//      OrderedServiceVO orderedServiceVO = new OrderedServiceVO();
////      secondSimOrderedServiceDTO.setOrderedServices(orderedServiceVO);
//    }
//    secondSimOrderedServiceGroupDTO.getSecondSimOrderedServiceDTOList().set(2,new SecondSimOrderedServiceDTO());

    secondSimOrderedServiceGroupDTO.setOrderId(1l);
    SecondSimOrderedServiceDTO secondSimOrderedServiceDTO = new SecondSimOrderedServiceDTO();
    OrderedServiceVO orderedServiceVO = new OrderedServiceVO();
    orderedServiceVO.setDefaultExpand(true);
    orderedServiceVO.setOfferCategoryId(123l);
    ArrayList<OrderedOffer> list1 = new ArrayList<>();
    OrderedOffer orderedOffer = new OrderedOffer();
    orderedOffer.setActiveDt("asda");
    orderedOffer.setBundleId(123l);
    list1.add(orderedOffer);
    orderedServiceVO.setOffers(list1);

    ArrayList<OrderedServiceVO> list2 = new ArrayList<>();
    list2.add(orderedServiceVO);
    secondSimOrderedServiceDTO.setOrderedServices(list2);
    //
    ArrayList<ServiceNumberExternal> list4 = new ArrayList<>();
    ServiceNumberExternal serviceNumberExternal = new ServiceNumberExternal();
    serviceNumberExternal.setExternalId("123");
    serviceNumberExternal.setChoose(true);
    serviceNumberExternal.setId(1234l);
    serviceNumberExternal.setExternalIdTypeName("jiegouces");
    list4.add(serviceNumberExternal);
    secondSimOrderedServiceDTO.setExternalObjectList(list4);


    // fajin
    OrderOffWaiVO orderOffWaiVO = new OrderOffWaiVO();
    orderOffWaiVO.setAmountSum(new BigDecimal(123));
    secondSimOrderedServiceDTO.setPenaltyVO(orderOffWaiVO);
    secondSimOrderedServiceDTO.setPenaltyVO(orderOffWaiVO);

    secondSimOrderedServiceDTO.setServiceNumber("fuwuhaoma");
    secondSimOrderedServiceDTO.setIsMainNumber(true);

    ArrayList<SecondSimOrderedServiceDTO> list3 = new ArrayList<>();
    list3.add(secondSimOrderedServiceDTO);
    secondSimOrderedServiceGroupDTO.setSecondSimOrderedServiceDTOList(list3);
    String s1 = json.toJSONString(secondSimOrderedServiceGroupDTO);
//    String s2 = secondSimOrderedServiceGroupDTO.toString();
//    System.out.println(s2);

//    System.out.println(s1);


    SecondSimOrderedServiceGroupDTO secondSimOrderedServiceGroupDTO1 = json.toJavaObject(SecondSimOrderedServiceGroupDTO.class);
    System.out.println(secondSimOrderedServiceGroupDTO1);


  }
}
